/**
 * Created by Jie on 2017/4/19.
 */
const mosca = require('mosca');
const moscaSetting = {
    port: 1883
};
const server = new mosca.Server(moscaSetting);
server.on('ready', () => {
    console.log('Mosca server is up and running')
});

server.on('clientConnected', (client) => {
    console.log('client connected', client.id);
});

server.on('clientDisconnecting', (client) => {
    console.log('client disconnecting', client.id);
});

server.on('clientDisconnected', (client) => {
    console.log('client disconnected', client.id);
});

// fired when a message is received
server.on('published', (packet, client) => {
    console.log('Published', packet.topic, packet.payload);
});

server.on('subscribed', (topic, client) => {
    console.log('subscribed', topic, client.id);
});

server.on('unsubscribed', (topic, client) => {
    console.log('unsubscribed', topic, client.id);
});
module.exports = server;